from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# confirm弹窗
driver = webdriver.Firefox()
# 打印当前尺寸
t1 = driver.get_window_size()
print(t1)
# 设置浏览器窗口大小
driver.set_window_size(600, 600)
sleep(3)
t2 = driver.get_cookie('cookieKey')
print(t2)
driver.get('file:///D:/qq/confirm.html')
driver.maximize_window()
# 打印当前尺寸
t1 = driver.get_window_size()
print(t1)
print(driver.title)
print(driver.current_url)
sleep(3)
# 刷新浏览器
driver.execute_script('window.location.reload();')
sleep(2)
ann = driver.find_element(By.ID, 'button')
print(ann.text)
ann.click()
sleep(2)
# 关闭弹窗
alert = driver.switch_to.alert
print(alert)
alert.dismiss()
# alert.accept()
sleep(2)
# 刷新浏览器
driver.refresh()
sleep(5)


